/**============================================================================
 Confidential Information - Limited distribution to authorized persons only.
 This software is protected as an unpublished work under the U.S. Copyright
 Act of 1976.

 Copyright (c) 2012, BluePhoenix Solutions, Inc. All rights reserved.
 ----------------------------------------------------------------------------
 file......: MetroButton.java
 Author....: Vyacheslav Kovalyov
 Created...: 2/15/12

 Description:

 ============================================================================*/
package ru.monyag.android.vibralarm.custom;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import ru.monyag.android.vibralarm.R;

/**
 * @author Vyacheslav Kovalyov
 * @version 1.0
 */
public class MetroButton extends LinearLayout {
    public MetroButton(Context context, AttributeSet attrs) {
        super(context, attrs);

        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.metro_icon, this);

        TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
                R.styleable.MetroButton, 0, 0);

        CharSequence s = a.getString(R.styleable.MetroButton_text);
        if (s != null) {
            ((TextView) findViewById(R.id.textView)).setText(s);
        }

        Drawable d = a.getDrawable(R.styleable.MetroButton_drawable);
        if (d != null) {
            ((ImageView) findViewById(R.id.imageView)).setImageDrawable(d);
        }

        a.recycle();
    }
}